package com.xja.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xja.bean.House;
import com.xja.mapper.HouseMapper;
import com.xja.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
@author 李岩
@date 2021/12/23-10:32
@describe
*/
@Service
public class HouseServiceImpl implements HouseService{

    @Autowired
    private HouseMapper houseMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return houseMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(House record) {
        return houseMapper.insert(record);
    }

    @Override
    public int insertSelective(House record) {
        return houseMapper.insertSelective(record);
    }

    @Override
    public House selectByPrimaryKey(Integer id) {
        return houseMapper.selectByPrimaryKey(id);
    }
    //查询所有的街道信息
    @Override
    public PageInfo<House> selectAllHouse(String pageNum, HashMap map) throws Exception {
        System.out.println("service  pageNum=  "+pageNum);
        int pageNumInt=1;
        int pageSizeInt=3;
        if (pageNum!=null && !"".equals(pageNum)){
            pageNumInt=Integer.valueOf(pageNum);
        }
        PageHelper.startPage(pageNumInt,pageSizeInt);
        List<House> list = houseMapper.selectAllHouse(map);
        PageInfo<House> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public PageInfo<House> selectAllHouse(String pageNum) throws Exception {
        System.out.println("service  pageNum=  "+pageNum);
        int pageNumInt=1;
        int pageSizeInt=3;
        if (pageNum!=null && !"".equals(pageNum)){
            pageNumInt=Integer.valueOf(pageNum);
        }
        PageHelper.startPage(pageNumInt,pageSizeInt);
        List<House> list = houseMapper.selectAllHouse();
        PageInfo<House> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int updateByPrimaryKeySelective(House record) {
        return houseMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(House record) {
        return houseMapper.updateByPrimaryKey(record);
    }

}
